package FlexTrade;

import java.io.Serializable;
import java.rmi.Remote;
import java.rmi.RemoteException;

import net.jini.core.entry.Entry;
import net.jini.core.event.EventRegistration;
import net.jini.core.event.RemoteEventListener;
import net.jini.core.transaction.server.TransactionManager;
import net.jini.core.transaction.server.TransactionParticipant;

public interface IAuction extends Remote, TransactionParticipant, Entry, Serializable {
	
	/*-----------------AUCTION STATUS--------------------------------*/
	static String AUCTION_STARTED = "Auction started";
	static String AUCTION_IN_PROGRESS = "Auction in Progress";
	static String AUCTION_FINISHED = "Auction finished";
	
	/*-----------------EVENT ID LIST--------------------------------*/
	//For English Auctions
	static int E_BID_PRICE_RECEIVED = 1001;
	static int E_AUCTION_FINISH = 1002;
	static int E_CUSTOMER_JOIN = 1003;
	static int E_AUCTION_TIMEOUT = 1004;
	//For Vickrey Auctions
	static int V_BID_PRICE_RECEIVED = 2001;
	static int V_AUCTION_FINISH = 2002;
	static int V_CUSTOMER_JOIN = 2003;
	static int V_AUCTION_TIMEOUT = 1004;
	//For Dutch Auctions
	static int D_ACCEPTABLE_PRICE_RECEIVED = 3001;
	static int D_AUCTION_FINISH = 3002;
	static int D_CUSTOMER_JOIN = 3003;
	static int D_CUSTOMER_ACCEPT = 3004;
	static int D_AUCTION_TIMEOUT = 3005;
	
	//payment transfer event
	static int PAYMENT_TRANSFERED_SUCCESSFULLY = 6001;
	static int CANNOT_TRANSFER_PAYMENT = 6002;
	
	public static int VICKREY_AUCTION_TYPE = 1;
	public static int ENGLISH_AUCTION_TYPE = 2;
	public static int DUTCH_AUCTION_TYPE = 3;
	
	
	//FlexTrade receive new bid for this auction (English/Vickrey) 
	boolean receiveBidPriceFromCustomer(BidPriceData _bidPriceData) throws RemoteException;
	
	//FlexTrade receive offer acceptance from customer (Dutch Auction)
	boolean receivePriceAcceptanceFromCustomer(BidPriceData _bidPriceData) throws RemoteException;
	
	//FlexTrade receive new offer from Provider (Dutch)
	boolean receiveNewAcceptablePriceFromProvider(float newAcceptablePrice) throws RemoteException;
	
	//add remote listener to this object
	public EventRegistration addRemoteListener(RemoteEventListener listener)
			throws java.rmi.RemoteException;
	
	public void setProxy(Remote _proxy) throws java.rmi.RemoteException;
	
	//public Object getProxy() throws java.rmi.RemoteException;
	
	//set the time duration that the auction will be held
	public void setAuctionTimeDuration(long timeDuration) throws java.rmi.RemoteException;
	
	public void setAuctionPrimitiveData(AuctionPrimitiveData _auctionPrimitiveData) 
							throws RemoteException;
	
	public AuctionPrimitiveData getAuctionPrimitiveData() throws RemoteException;
	
	public String getUniqueAuctionID() throws RemoteException;
	
	//transfer the payment from customer bank account to provider bank account
	public boolean paymentTransfer(float amount, String customerID, String providerID,
					TransactionManager mgr, long transactionID) throws RemoteException;
	
	public BidPriceData getLastBidPriceData() throws RemoteException;
	
	public AuctionStates getCurrentAuctionStates() throws RemoteException;
	
	//get information about the last customer that joined the auction
	//in order to notify other customers already participating in that auction
	public CustomerData getLastJoinCustomer() throws RemoteException;
}
